import request from '/@/utils/request'
import requestFile from '/@/utils/requestFile'
const serverContextPath = '/report'
export function reportApi() {
	return {
		serverContextPath: serverContextPath,
		/**
		 * 分页查询
		 * @param {'page': this.pageIndex,
					'limit': this.pageSize,
					'dataForm': this.dataForm} params 
		*/
		queryPage: (params: any) => {
			return request({
				url: serverContextPath + '/ureportc/filetbl/list',
				method: 'post',
				data: params
			})
		},

		/**
		 * 上传文件
		 * @param {*} formData 
		 */
		importReport: (formData: any) => {
			return requestFile({
				url: serverContextPath + '/ureportc/filetbl/importReport',
				method: 'post',
				data: formData
			})
		},

		/**
		 * 下载文件
		 * @param {*} id 
		 */
		downloadFile: (id: any) => {
			var a = document.createElement("a");
			a.href = import.meta.env.VITE_API_URL + serverContextPath + "/ureportc/filetbl/downloadFile/" + id
			a.click();
		},

		/**
		 * 删除文件
		 * @param {*} id 
		 */
		delete: (id: any) => {
			return request({
				url: serverContextPath + "/ureportc/filetbl/delete",
				method: "post",
				data: id
			})
		},
		// 预览、查询大屏详情
		getReportDetailDashboard: (reportCode: string) => {
			return request({
				url: serverContextPath + '/bigscreen/reportDashboard/getReportDetailDashboard/' + reportCode,
				method: 'get',
			})
		},
		// 获取动态数据
		getChartsData: (data: any) => {
			return request({
				url: serverContextPath + '/bigscreen/reportDashboard/getChartsData',
				method: 'post',
				data: data,
			})
		},
		insertDashboard: (data: any) => {
			return request({
				url: serverContextPath + '/bigscreen/reportDashboard/insertDashboard',
				method: 'post',
				data: data,
			})
		},
		//分页查询数据源
		queryReportDataSourceList: (params: any) => {
			return request({
				url: serverContextPath + '/datas/reportDataSource/list',
				method: 'post',
				data: params
			})
		},
		//根据主键查询数据源
		queryReportDataSourceInfo: (id: string) => {
			return request({
				url: serverContextPath + '/datas/reportDataSource/info/' + id,
				method: 'get',
			})
		},
		//删除数据源数据
		deleteReportDataSourceById: (ids: string[]) => {
			return request({
				url: serverContextPath + '/datas/reportDataSource/delete',
				method: 'post',
				data: ids
			})
		},
		//新增数据源数据
		saveReportDataSource: (data: any) => {
			return request({
				url: serverContextPath + '/datas/reportDataSource/save',
				method: 'post',
				data: data
			})
		},
		//修改数据源数据
		updateReportDataSource: (data: any) => {
			return request({
				url: serverContextPath + '/datas/reportDataSource/update',
				method: 'post',
				data: data
			})
		},
		//测试数据源连接
		testReportDataSourceConnection: (data: any) => {
			return request({
				url: serverContextPath + '/datas/reportDataSource/test',
				method: 'post',
				data: data
			})
		},
		//获取所有数据源{key,value}
		getDataSourceOptionsAll: () => {
			return request({
				url: serverContextPath + '/datas/reportDataSource/kvAll',
				method: 'get',
			})
		},
		//分页查询数据集
		queryReportDatasetList: (params: any) => {
			return request({
				url: serverContextPath + '/datas/reportDataset/list',
				method: 'post',
				data: params
			})
		},
		//数据预览，根据界面规则预览
		testTransformSet: (data: any) => {
			return request({
				url: serverContextPath + '/datas/reportDataset/testTransform',
				method: 'post',
				data: data
			})
		},
		//数据预览，根据数据集id（已设置的数据集规则）预览
		testTransformSetBySetId: (id: string) => {
			return request({
				url: serverContextPath + '/datas/reportDataset/testTransformSetBySetId/' + id,
				method: 'get'
			})
		},
		//新增数据集
		saveDataSet: (data: any) => {
			return request({
				url: serverContextPath + '/datas/reportDataset/save',
				method: 'post',
				data: data
			})
		},
		//修改数据集
		updateDataSet: (data: any) => {
			return request({
				url: serverContextPath + '/datas/reportDataset/update',
				method: 'post',
				data: data
			})
		},
		//根据主键查数据集信息
		getDataSetById: (id: string) => {
			return request({
				url: serverContextPath + '/datas/reportDataset/info/' + id,
				method: 'get',
			})
		},
		// 数据集高级规则js验证
		verificationSet: (data: any) => {
			return request({
				url: serverContextPath + '/datas/reportDataset/verificationSet',
				method: 'post',
				data: data
			})
		},
		//查询所有数据集
		queryAllDataSet:() => {
			return request({
				url: serverContextPath + '/datas/reportDataset/queryAllDataSet',
				method: 'get',
			})
		},
		detailBysetId: (id: string) => {
			return request({
				url: serverContextPath + '/datas/reportDataset/detailBysetId/' + id,
				method: 'get',
			})
		},
		//分页查询报表
		queryReportMngList: (params: any) => {
			return request({
				url: serverContextPath + '/reportMng/report/list',
				method: 'get',
				params: params
			})
		},
		//根据主键查询报表
		queryReportMngInfo: (id: string) => {
			return request({
				url: serverContextPath + '/reportMng/report/info/' + id,
				method: 'get',
			})
		},
		//删除报表数据
		deleteReportMngById: (ids: string[]) => {
			return request({
				url: serverContextPath + '/reportMng/report/delete',
				method: 'post',
				data: ids
			})
		},
		//新增报表数据
		saveReportMngSource: (data: any) => {
			return request({
				url: serverContextPath + '/reportMng/report/save',
				method: 'post',
				data: data
			})
		},
		//修改报表数据
		updateReportMngSource: (data: any) => {
			return request({
				url: serverContextPath + '/reportMng/report/update',
				method: 'post',
				data: data
			})
		},
	}
}